package com.mongo.controller;

import com.mongo.entity.User;
import com.mongo.service.MongoService;
import com.mongodb.client.result.UpdateResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yuhuan
 * @date 2025/4/18
 */
@RestController
@RequestMapping("/mongo")
public class MongoController {

    @Autowired
    MongoService mongoService;

    @PostMapping("/save")
    public UpdateResult save(@RequestBody User user) {
        return mongoService.save(user);
    }

    @PostMapping("/add")
    public User add(@RequestBody User user) {
        return mongoService.add(user);
    }

    @PutMapping("/edit")
    public UpdateResult edit(@RequestBody User user) {
        return mongoService.edit(user);
    }
}
